package number

// https://leetcode-cn.com/leetbook/read/top-interview-questions-easy/xncfnv/
// 杨辉三角
// 直接计算即可
func generate(numRows int) (ret [][]int) {
	ret = make([][]int, numRows)
	if 0 == numRows {
		return
	}
	ret[0] = []int{1}
	if 1 == numRows {
		return
	}
	ret[1] = []int{1, 1}
	for index := 2; index < numRows; index++ {
		arrLen := index + 1
		ret[index] = make([]int, arrLen)
		for pos := 0; pos < arrLen; pos++ {
			if 0 == pos {
				ret[index][pos] = 1
			} else if pos == arrLen-1 {
				ret[index][pos] = 1
			} else {
				ret[index][pos] = ret[index-1][pos] + ret[index-1][pos-1]
			}
		}
	}
	return
}
